using System;
using NLite.Internal;

namespace NLite
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public struct Disposable
    {
        /// <summary>
        /// 
        /// </summary>
        public static readonly IDisposable Empty = new EmptyDisposeAction();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static IDisposable Create(Action action)
        {
            return new ActionDisposable(action);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static IDisposable Create(object owner, Action action)
        {
            return new ActionDisposable(owner,action);
        }
    }
}
